Skip to content

Conversation

@zharinov
Copy link
Member

@zharinov zharinov commented Jan 3, 2026

Summary

  • Fix bug where labeled alternation variants referencing named definitions with captures produced empty $data: {}
  • The type system already correctly inferred $data: { name: Node }, but runtime materialization discarded the value

Problem

When a labeled alternation variant references a named definition containing captures:

Inner = (identifier) @name
Plugin = [A: (Inner)]

The $data field was empty {} instead of containing { name: Node }.

Root Cause

In materializer.rs, EndEnum was discarding any pending value from an inner definition's Obj/EndObj and constructing $data from the empty fields vector.

Fix

Modified EndEnum to consume the pending value if available:

let data = pending.take().unwrap_or_else(|| Value::Object(fields));

Test plan

  • Added regression test alternations_tagged_with_definition_ref
  • All 751 tests pass
  • Verified fix with manual testing

@zharinov zharinov enabled auto-merge (squash) January 3, 2026 17:21
@zharinov zharinov force-pushed the fix/labeled-alt-def-ref branch from 72e0c73 to f8cb0d6 Compare January 3, 2026 17:25
@zharinov zharinov merged commit d55d417 into master Jan 3, 2026
4 checks passed
@zharinov zharinov deleted the fix/labeled-alt-def-ref branch January 3, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants